var i;
Object.defineProperty(exports, "__esModule", {
  value: true
});
var UI_GameView_UIBindings = require("AA_UI_GameView_UIBindings");
var UIView = require("AA_UIView");
var EventManager = require("AA_EventManager");
var EvenType = require("AA_EvenType");
var Excel = require("AA_Excel");
var NodePoolMag = require("AA_NodePoolMag");
var BundleConfig = require("AA_BundleConfig");
var UI_MosterLogic = require("AA_UI_MosterLogic");
var GameGlobalVariable = require("AA_GameGlobalVariable");
var UI_Player = require("AA_UI_Player");
var UI_ShowAttackInfo = require("AA_UI_ShowAttackInfo");
var UIManager = require("AA_UIManager");
var UIConfig_Game = require("AA_UIConfig_Game");
var CommonUtils = require("AA_CommonUtils");
var BuffMag = require("AA_BuffMag");
var UI_Bullet = require("AA_UI_Bullet");
var GameDataManager = require("AA_GameDataManager");
var UIConfig_Home = require("AA_UIConfig_Home");
var UI_DuWu = require("AA_UI_DuWu");
var UI_Bag = require("AA_UI_Bag");
var ExcelUtil = require("AA_ExcelUtil");
var UI_BulletBomb = require("AA_UI_BulletBomb");
var UI_BulletMove = require("AA_UI_BulletMove");
var AudioManager = require("AA_AudioManager");
var LogManager = require("AA_LogManager");
var PlayerDataManager = require("AA_PlayerDataManager");
var Const_Common = require("AA_Const_Common");
var TipsManager = require("AA_TipsManager");
var UI_GameViewMap = require("AA_UI_GameViewMap");
var UI_CreateMoster = require("AA_UI_CreateMoster");
var UI_SkillShow = require("AA_UI_SkillShow");
var GuideControl = require("AA_GuideControl");
var UI_BulletBang = require("AA_UI_BulletBang");
var UI_BulletDaBang = require("AA_UI_BulletDaBang");
var ResLoader = require("AA_ResLoader");
var UIConfig_Common = require("AA_UIConfig_Common");
var _decorator = cc._decorator;
var _ccclass = _decorator.ccclass;
var _property = _decorator.property;

var _def_UI_GameView = function (e) {
  function _creator() {
    var t = null !== e && e.apply(this, arguments) || this;
    t.auto_ui = null;
    t.UI_BagNode = null;
    t.mosterNode = null;
    t.pathsNode = null;
    t.playerNode = null;
    t.bulletNode = null;
    t.languaNode = null;
    t.liulianNode = null;
    t.othereff = null;
    t.aixinNode = null;
    t.mapNode = null;
    t.tiaozhanTip = null;
    t.tongjiNode = null;
    t.bottmoNode = null;
    t.jinjieEffNode = null;
    t.playereffNode = null;
    t.addYinBiBtn = null;
    t.boosTip = null;
    t.fankuiNode = null;
    t.showattackinfo = null;
    t.mosterScript = null;
    t.bottomNd = null;
    t.isgamepuase = true;
    t.jiasuCode = 1;
    t.isadd = false;
    t.defY = 0;
    t.nowlevel = 1;
    t.xueliang = 3;
    t.fuhuocount = 0;
    t.maxcount = 1;
    t.isover = false;
    t.isOpenPuase = false;
    t.isGameOver = false;
    t.overstate = -1;
    t.addbool = false;
    t.rolelevel = 1;
    t.roleexperience = 0;
    t.isCiTiaoOpen = false;
    t.nowBag = null;
    return t;
  }
  __extends(_creator, e);
  _creator.prototype.onLoad = function () {
    ResLoader.default.loadBundle(BundleConfig.BundleNames.Home).then(function () { });
  };
  _creator.prototype._show = function (e) {
    var t = this;
    var o = [];
    for (var n = 1; n < arguments.length; n++) {
      o[n - 1] = arguments[n];
    }
    GameGlobalVariable.GameGlobalVariable.diyicijin = false;
    this.scheduleOnce(function () { }, 3);
    LogManager.LogMgr.info("登陆时间", new Date().getTime() - GameGlobalVariable.GameGlobalVariable.offtime);
    this.mosterScript = this.mosterNode.getComponent(UI_CreateMoster.default);
    this.mosterScript.setOver(this.isOver.bind(this));
    this.tiaozhanTip.active = false;
    AudioManager.AudioMgr.playMusic("game/sound/gamebgm", true, BundleConfig.BundleNames.Game);
    if (1 == GameGlobalVariable.GameGlobalVariable.isTeShuLevel()) {
      GameGlobalVariable.GameGlobalVariable.huanyipi = ExcelUtil.ExcelUtil.getSameData(Excel.Excel.shuiguoconfig_all, "configkey", "huanyipin")[0].value;
      GameGlobalVariable.GameGlobalVariable.allhave = ExcelUtil.ExcelUtil.getSameData(Excel.Excel.shuiguoconfig_all, "configkey", "allhave")[0].value;
      if (!GameDataManager.GameDataMgr.getJiXuTiaoZhan()) {
        GameDataManager.GameDataMgr.ClearGameBagData();
        this.nowlevel = GameGlobalVariable.GameGlobalVariable.teshulevel;
        var i = GameGlobalVariable.GameGlobalVariable.getWuJinYinBiCount();
        GameDataManager.GameDataMgr.AddSliderCoin(i - 15);
      }
      GameDataManager.GameDataMgr.updateTiaoZhanJiXu(this.nowlevel, true);
      this.maxcount = GameGlobalVariable.GameGlobalVariable.wujinfuhuocount;
    } else {
      this.maxcount = GameGlobalVariable.GameGlobalVariable.putongfuhuocount;
      this.nowlevel = GameGlobalVariable.GameGlobalVariable.nowlevel;
      if (BuffMag.BuffMgr.ciTiaoData && BuffMag.BuffMgr.ciTiaoData.length > 0) {
        var a = GameDataManager.GameDataMgr.getJiXuGame();
        this.mosterScript.mosterboshu = a.nowboshu;
        GameGlobalVariable.GameGlobalVariable.huanyipi = GameDataManager.GameDataMgr.getCiTiaoCount(GameGlobalVariable.GameGlobalVariable.nowlevel, 1);
        GameGlobalVariable.GameGlobalVariable.allhave = GameDataManager.GameDataMgr.getCiTiaoCount(GameGlobalVariable.GameGlobalVariable.nowlevel, 2);
        if (GameDataManager.GameDataMgr.getRoleLevel(this.nowlevel, GameGlobalVariable.GameGlobalVariable.isTeShuLevel())) {
          var r = GameDataManager.GameDataMgr.getRoleLevel(this.nowlevel, GameGlobalVariable.GameGlobalVariable.isTeShuLevel());
          this.rolelevel = r.level;
          this.roleexperience = 0;
        } else {
          this.rolelevel = 1;
        }
      } else {
        GameGlobalVariable.GameGlobalVariable.huanyipi = ExcelUtil.ExcelUtil.getSameData(Excel.Excel.shuiguoconfig_all, "configkey", "huanyipin")[0].value;
        GameGlobalVariable.GameGlobalVariable.allhave = ExcelUtil.ExcelUtil.getSameData(Excel.Excel.shuiguoconfig_all, "configkey", "allhave")[0].value;
        GameDataManager.GameDataMgr.updateLevelBoShu(this.nowlevel, this.mosterScript.mosterboshu, GameGlobalVariable.GameGlobalVariable.isTeShuLevel());
        PlayerDataManager.PlayerDataMgr.GetGuideIndexByTaskName(Const_Common.GuideName.战斗背包) == Const_Common.GameBagGuideIndex.引导完结 && GameDataManager.GameDataMgr.ClearGameBagData();
        GameDataManager.GameDataMgr.ClearGameBagData();
      }
    }
    GameGlobalVariable.GameGlobalVariable.bulletNode = this.bulletNode;
    GameGlobalVariable.GameGlobalVariable.languaNode = this.languaNode;
    GameGlobalVariable.GameGlobalVariable.liulianNode = this.liulianNode;
    GameGlobalVariable.GameGlobalVariable.mosterNode = this.mosterNode;
    GameGlobalVariable.GameGlobalVariable.effNode = this.othereff;
    GameGlobalVariable.GameGlobalVariable.jinjieeffNode = this.jinjieEffNode;
    GameGlobalVariable.GameGlobalVariable.playereffNode = this.playereffNode;
    GameGlobalVariable.GameGlobalVariable.paths = this.pathsNode;
    GameGlobalVariable.GameGlobalVariable.nowlevelhuobi = 0;
    this.initUi();
    this.showattackinfo.addEvent();
    this.auto_ui.dbAnim_openGame.node.active = false;
    this.scheduleOnce(function () {
      t.loadBottom();
    }, .5);
    this.isover = false;
    GameGlobalVariable.GameGlobalVariable.openName("Game");
  };
  _creator.prototype.loadBottom = function () {
    return __awaiter(this, undefined, undefined, function () {
      var e;
      return __generator(this, function (t) {
        switch (t.label) {
          case 0:
            if (this.bottomNd) {
              return [3, 2];
            } else {
              return [4, this._loadRes(BundleConfig.BundleNames.Game, "game/" + "prefabs/bottomNode", cc.Prefab)];
            }
          case 1:
            e = t.sent();
            this.bottomNd = cc.instantiate(e);
            t.label = 2;
          case 2:
            this.bottmoNode.addChild(this.bottomNd);
            this.bottomNd.x = this.bottomNd.y = 0;
            return [2];
        }
      });
    });
  };
  _creator.prototype.openFanKui = function () {
    UIManager.default.open(BundleConfig.BundleNames.Common, UIConfig_Common.UIView_Common.FanKuiView);
  };
  _creator.prototype._close = function () {
    e.prototype._close.call(this);
    this.showattackinfo.rmEvent();
    BuffMag.BuffMgr.resetNowGuo();
    NodePoolMag.NodePoolMag.instance.clearAllNode();
    cc.game.setFrameRate(60);
  };
  _creator.prototype._addEventListener = function () {
    this._addEvent(EvenType.EVENT_TYPE.Game_Update, this.onBeiLvUpdate, this);
    this._addEvent(EvenType.EVENT_TYPE.Game_Moster_DIE, this.onMosterDie, this);
    this._addEvent(EvenType.EVENT_TYPE.Game_Moster_Attack, this.onJianXue, this);
    this._addEvent(EvenType.EVENT_TYPE.Game_OpenGame, this.onStartGame, this);
    this._addEvent(EvenType.EVENT_TYPE.Game_CreateDuWu, this.createDuWu, this);
    this._addEvent(EvenType.EVENT_TYPE.GAME_BackHall, this.backView, this);
  };
  _creator.prototype.createDuWu = function (e, t, o) {
    return __awaiter(this, undefined, undefined, function () {
      var n;
      var i;
      return __generator(this, function (a) {
        switch (a.label) {
          case 0:
            if (n = NodePoolMag.NodePoolMag.instance.getNode("duwu")) {
              return [3, 2];
            } else {
              return [4, this._loadRes(BundleConfig.BundleNames.Game, "game/" + "prefabs/effpre/UI_DuWu", cc.Prefab)];
            }
          case 1:
            i = a.sent();
            NodePoolMag.NodePoolMag.instance.createNodeCount("duwu", 1, i);
            n = NodePoolMag.NodePoolMag.instance.getNode("duwu");
            a.label = 2;
          case 2:
            n.x = e.node.x;
            n.y = e.node.y;
            if (1 == e.moveindex || 3 == e.moveindex || 5 == e.moveindex) {
              n.angle = 0;
            } else {
              n.angle = 90;
            }
            this.othereff.addChild(n);
            n.getComponent(UI_DuWu.default).initInfo(t, o);
            return [2];
        }
      });
    });
  };
  _creator.prototype.onBeiLvUpdate = function (e) {
    switch (this.jiasuCode) {
      case 1:
        this.onUpdate(e);
        break;
      case 2:
        this.onUpdate(e);
        this.onUpdate(e);
        break;
      case 3:
        this.onUpdate(e);
        this.onUpdate(e);
        this.onUpdate(e);
    }
  };
  _creator.prototype.onDisable = function () {
    GameGlobalVariable.GameGlobalVariable.cleanAttack();
  };
  _creator.prototype.onUpdate = function (e) {
    if (!this.isgamepuase) {
      this.mosterScript.onCreateMoster(e);
      this.setPlayState(e);
      this.setMosterState(e);
      this.bulletUpDate(e);
      this.otherEffUpdate(e);
    }
  };
  _creator.prototype.otherEffUpdate = function (e) {
    this.othereff.getComponentsInChildren(UI_DuWu.default).forEach(function (t) {
      t.onUpdate(e);
    });
  };
  _creator.prototype.bulletUpDate = function (e) {
    var t = this;
    GameGlobalVariable.GameGlobalVariable.bulletNode.getComponentsInChildren(UI_Bullet.default).forEach(function (t) {
      t.onUpdate(e);
    });
    GameGlobalVariable.GameGlobalVariable.playereffNode.children.forEach(function (t) {
      var o = t.getComponent(UI_BulletBang.default);
      o && o.onUpdate(e);
      var n = t.getComponent(UI_BulletDaBang.default);
      n && n.onUpdate(e);
    });
    var o = GameGlobalVariable.GameGlobalVariable.languaNode.getComponentsInChildren(UI_BulletBomb.default);
    var n = 0;
    var i = [];
    o.forEach(function (t) {
      t.node.zIndex = -2;
      i.push(t);
      t.onUpdate(e);
      n += 1;
    });
    if (n > 100) {
      i.sort(function (e, t) {
        if (e.createtime < t.createtime) {
          return -1;
        } else {
          return 1;
        }
      });
      i.shift().hideBullet();
    }
    GameGlobalVariable.GameGlobalVariable.LanGuaPaiXu(i, this.mosterNode);
    i.forEach(function (e) {
      e.getComponent(UI_BulletBomb.default).pengZhuangMoster(t.mosterNode);
    });
    GameGlobalVariable.GameGlobalVariable.liulianNode.getComponentsInChildren(UI_BulletMove.default).forEach(function (t) {
      t.node.zIndex = -1;
      t.onUpdate(e);
    });
  };
  _creator.prototype.ceshiDaYin = function () { };
  _creator.prototype.setPlayState = function (e) {
    this.playerNode.getComponentsInChildren(UI_Player.default).forEach(function (t) {
      t.node.active && t.onUpdate(e);
    });
  };
  _creator.prototype.setMosterState = function (e) {
    this.mosterNode.getComponentsInChildren(UI_MosterLogic.default).forEach(function (t) {
      t.onUpdate(e);
    });
    var t = GameGlobalVariable.GameGlobalVariable.paixuMoster(this.mosterNode);
    var o = 999;
    t.forEach(function (e) {
      e.script.node.zIndex = o;
      o -= 1;
    });
  };
  _creator.prototype.onClose = function () { };
  _creator.prototype._clickListener = function (e) {
    var t = this.auto_ui;
    switch (e) {
      case t.btn_back:
        if (PlayerDataManager.PlayerDataMgr.GetGuideIndexByTaskName(Const_Common.GuideName.战斗背包) < Const_Common.GameBagGuideIndex.引导完结) {
          return void TipsManager.TipMgr.showToast("请先完成引导章节挑战");
        }
        this.onClickBack();
        break;
      case t.btn_jiasuNode:
        this.onClickJiaShu();
    }
  };
  _creator.prototype.resetJiaShu = function () {
    cc.director.getScheduler().setTimeScale(1);
  };
  _creator.prototype.setJiaShuState = function (e) {
    this.jiasuCode = e;
    switch (this.jiasuCode) {
      case 1:
        cc.director.getScheduler().setTimeScale(1);
        this.auto_ui.btn_jiasuNode.node.children[3].active = false;
        this.auto_ui.btn_jiasuNode.node.children[2].active = true;
        this.auto_ui.btn_jiasuNode.node.children[4].active = false;
        break;
      case 2:
        cc.director.getScheduler().setTimeScale(2);
        this.auto_ui.btn_jiasuNode.node.children[3].active = true;
        this.auto_ui.btn_jiasuNode.node.children[2].active = false;
        this.auto_ui.btn_jiasuNode.node.children[4].active = false;
        break;
      case 3:
        cc.director.getScheduler().setTimeScale(3);
        this.auto_ui.btn_jiasuNode.node.children[3].active = false;
        this.auto_ui.btn_jiasuNode.node.children[2].active = false;
        this.auto_ui.btn_jiasuNode.node.children[4].active = true;
    }
  };
  _creator.prototype.onClickJiaShu = function () {
    switch (this.jiasuCode) {
      case 1:
        2 != GameGlobalVariable.GameGlobalVariable.beishustate && 3 != GameGlobalVariable.GameGlobalVariable.beishustate || this.setJiaShuState(2);
        break;
      case 2:
        if (3 == GameGlobalVariable.GameGlobalVariable.beishustate) {
          this.setJiaShuState(3);
        } else {
          this.setJiaShuState(1);
        }
        break;
      case 3:
        this.setJiaShuState(1);
    }
  };
  _creator.prototype.getMaxCount = function () {
    return GameGlobalVariable.GameGlobalVariable.beishustate;
  };
  _creator.prototype.onBackGame = function () {
    BuffMag.BuffMgr.cleanLiuLian();
    this.mosterScript.isCreateMoster = false;
    this.setGamePuase(true);
    this.setNodeState(2);
    EventManager.EventMgr.dispatchEvent(EvenType.EVENT_TYPE.Game_CameraControl, 1);
    this.resetGame();
  };
  _creator.prototype.resetGame = function () {
    switch (this.overstate) {
      case 1:
        this.resetJiaShu();
        this.mosterScript.mosterboshu++;
        GameDataManager.GameDataMgr.updateLevelBoShu(this.nowlevel, this.mosterScript.mosterboshu, GameGlobalVariable.GameGlobalVariable.isTeShuLevel());
        break;
      case 2:
        this.xueliang = 3;
        break;
      case 3:
        this.mosterScript.mosterboshu = 0;
        this.xueliang = 3;
    }
    this.setGamePuase(false);
    this.mosterScript.huishouMoster();
    this.updateLun();
  };
  _creator.prototype.setGamePuase = function (e) {
    this.isgamepuase = e;
    GameGlobalVariable.GameGlobalVariable.gamepuase = e;
  };
  _creator.prototype.onStartGame = function () {
    var e = this;
    this.overstate = -1;
    if (GameGlobalVariable.GameGlobalVariable.diyicijin) {
      this.setJiaShuState(this.jiasuCode);
    } else {
      GameGlobalVariable.GameGlobalVariable.diyicijin = true;
      if (1 == GameGlobalVariable.GameGlobalVariable.nowlevel) {
        this.setJiaShuState(this.jiasuCode);
      } else {
        this.setJiaShuState(this.getMaxCount());
      }
    }

    console.log("GameStart~~~~~~~~~~~~~~");
    this.addAdTimes = this.addAdTimes || 0;
    this.addAdTimes++;
    if (this.addAdTimes > 2) {
      this.addAdTimes = 0;
      cc.systemEvent.emit('showExpressAdInGame', 4);
    }



    this.setGamePuase(false);
    this.setNodeState(1);
    this.scheduleOnce(function () {
      EventManager.EventMgr.dispatchEvent(EvenType.EVENT_TYPE.Game_CameraControl, .68);
    }, .3);
    this.scheduleOnce(function () {
      e.auto_ui.dbAnim_openGame.node.active = true;
      e.auto_ui.dbAnim_openGame.playAnimation("newAnimation", 1);
      AudioManager.AudioMgr.playEffect("game/sound/pengzhuang", false, BundleConfig.BundleNames.Game);
    }, .6);
    this.scheduleOnce(function () {
      e.auto_ui.dbAnim_openGame.node.active = false;
    }, 1.5);
    this.scheduleOnce(function () {
      e.playGame();
    }, .5);
  };
  _creator.prototype.onTiaoZhanGame = function () {
    this.overstate = -1;
    this.setJiaShuState(this.jiasuCode);
    this.setGamePuase(false);
    this.playGame();
  };
  _creator.prototype.setNodeState = function (e) {
    var t = this;
    switch (e) {
      case 1:
        this.scheduleOnce(function () {
          t.UI_BagNode.active = false;
          t.mapNode.y = 0;
          t.mapNode.opacity = 255;
          t.updateLun();
        }, .3);
        this.auto_ui.node_shuimitao.active = true;
        this.auto_ui.node_shuimitao.opacity = 0;
        cc.tween(this.auto_ui.node_shuimitao).to(.5, {
          opacity: 255
        }).start();
        this.auto_ui.node_chaoxue.active = true;
        this.auto_ui.node_chaoxue.opacity = 0;
        cc.tween(this.auto_ui.node_chaoxue).to(.5, {
          opacity: 255
        }).start();
        this.auto_ui.btn_jiasuNode.node.active = true;
        this.auto_ui.btn_jiasuNode.node.opacity = 0;
        cc.tween(this.auto_ui.btn_jiasuNode.node).to(.5, {
          opacity: 255
        }).delay(1).call(function () {
          if (PlayerDataManager.PlayerDataMgr.GetGuideIndexByTaskName(Const_Common.GuideName.战斗背包) == Const_Common.GameBagGuideIndex.引导词条7) {
            t.setGamePuase(true);
            var e = t.auto_ui.btn_jiasuNode.node;
            var o = e.convertToWorldSpaceAR(cc.v2(0, 0));
            var n = cc.size(e.width, e.height);
            GuideControl.GuideCtrl.ShowGuide({
              callBack: function () {
                t.setJiaShuState(2);
                t.setGamePuase(false);
              },
              sayStr: "点击加速战斗体验更佳",
              sayNodePos: cc.v2(0, 0),
              wPos: o,
              size: n
            });
          }
        }).start();
        this.aixinNode.active = true;
        this.aixinNode.opacity = 0;
        cc.tween(this.aixinNode).to(.5, {
          opacity: 255
        }).start();
        this.auto_ui.node_lu.active = true;
        this.auto_ui.node_lu.opacity = 0;
        cc.tween(this.auto_ui.node_lu).to(.5, {
          opacity: 255
        }).start();
        this.tongjiNode.active = true;
        this.tongjiNode.opacity = 0;
        cc.tween(this.tongjiNode).to(.5, {
          opacity: 255
        }).start();
        this.playerNode.active = true;
        this.playerNode.opacity = 0;
        cc.tween(this.playerNode).to(.5, {
          opacity: 255
        }).start();
        this.jinjieEffNode.active = true;
        this.jinjieEffNode.opacity = 0;
        cc.tween(this.jinjieEffNode).to(.5, {
          opacity: 255
        }).start();
        this.playereffNode.active = true;
        this.playereffNode.opacity = 0;
        cc.tween(this.playereffNode).to(.5, {
          opacity: 255
        }).start();
        this.bottmoNode.active = true;
        this.bottmoNode.opacity = 0;
        cc.tween(this.bottmoNode).to(.5, {
          opacity: 255
        }).start();
        0 == this.defY && (this.defY = this.fankuiNode.y);
        cc.tween(this.fankuiNode).to(.5, {
          y: this.defY - 100
        }).start();
        cc.tween(this.boosTip).to(.5, {
          opacity: 0
        }).call(function () {
          t.boosTip.active = false;
        }).start();
        this.addYinBiBtn.active = false;
        EventManager.EventMgr.dispatchEvent(EvenType.EVENT_TYPE.GAME_HIDE_CLICK);
        cc.game.setFrameRate(59);
        break;
      case 2:
        EventManager.EventMgr.dispatchEvent(EvenType.EVENT_TYPE.GAME_HIDE_TONGJI);
        cc.tween(this.mapNode).to(.5, {
          y: 100
        }).start();
        cc.tween(this.playerNode).to(.5, {
          y: 100
        }).start();
        this.scheduleOnce(function () {
          t.mapNode.getComponent(UI_GameViewMap.default).huishouNode();
          t.mapNode.opacity = 0;
          t.mapNode.y = 0;
          t.playerNode.y = 0;
          t.playerNode.active = false;
          t.UI_BagNode.active = true;
          t.boosTip.active = true;
          t.boosTip.opacity = 255;
          t.UI_BagNode.children[0].getComponent(UI_Bag.default).OpenView({
            isGameEnd: true
          });
          t.updateLun();
        }, .6);
        cc.tween(this.auto_ui.node_shuimitao).to(.5, {
          opacity: 0
        }).call(function () {
          t.auto_ui.node_shuimitao.active = false;
        }).start();
        cc.tween(this.auto_ui.node_chaoxue).to(.5, {
          opacity: 0
        }).call(function () {
          t.auto_ui.node_chaoxue.active = false;
        }).start();
        cc.tween(this.auto_ui.btn_jiasuNode.node).to(.5, {
          opacity: 0
        }).call(function () {
          t.auto_ui.btn_jiasuNode.node.active = false;
        }).start();
        cc.tween(this.aixinNode).to(.5, {
          opacity: 0
        }).call(function () {
          t.aixinNode.active = false;
        }).start();
        cc.tween(this.auto_ui.node_lu).to(.5, {
          opacity: 0
        }).call(function () {
          t.auto_ui.node_lu.active = false;
        }).start();
        cc.tween(this.jinjieEffNode).to(.5, {
          opacity: 0
        }).call(function () {
          t.jinjieEffNode.active = false;
        }).start();
        cc.tween(this.playereffNode).to(.5, {
          opacity: 0
        }).call(function () {
          t.playereffNode.active = false;
        }).start();
        cc.tween(this.bottmoNode).to(.5, {
          opacity: 0
        }).call(function () {
          t.bottmoNode.active = false;
        }).start();
        0 == this.defY && (this.defY = this.fankuiNode.y);
        cc.tween(this.fankuiNode).to(.5, {
          y: this.defY
        }).start();
        EventManager.EventMgr.dispatchEvent(EvenType.EVENT_TYPE.GAME_HIDE_CLICK);
        this.addYinBiBtn.active = true;
        cc.game.setFrameRate(60);
        cc.winSize.height / cc.winSize.width < 2 && cc.tween(this.tongjiNode).to(.5, {
          opacity: 0
        }).call(function () {
          t.tongjiNode.active = false;
        }).start();
    }
  };
  _creator.prototype.playGame = function () {
    this.mosterScript.initMoster();
    this.updateExperienceUi();
    this.updateXue();
  };
  _creator.prototype.onJianXue = function (e) {
    if (!this.isover) {
      var t = e.mosterId;
      var o = 1;
      1 == Excel.Excel.shuiguoguaiwu(t).boss && (o = 3);
      EventManager.EventMgr.dispatchEvent(EvenType.EVENT_TYPE.COMMON_SHAK);
      this.xueliang -= o;
      window.mg && mg.vibrateShort();
      this.xueliang < 0 && (this.xueliang = 0);
      AudioManager.AudioMgr.playEffect("game/sound/abb", false, BundleConfig.BundleNames.Game);
      this.updateXue();
      if (this.xueliang <= 0) {
        this.isover = true;
        this.mosterScript.isCreateMoster = false;
        this.setGamePuase(true);
        this.resetJiaShu();
        if (this.fuhuocount < this.maxcount) {
          this.fuhuocount += 1;
          UIManager.default.open(BundleConfig.BundleNames.Game, UIConfig_Game.UIView_Game.UI_GameFail, {
            back: this.onBack.bind(this),
            type: GameGlobalVariable.GameGlobalVariable.isTeShuLevel()
          });
        } else {
          this.onBack(4);
        }
      }
    }
  };
  _creator.prototype.updateXue = function () {
    var e = this.aixinNode.children;
    for (var t = 0; t < e.length; t++) {
      var o = e[t];
      if (this.xueliang < t + 1) {
        o.children[0].active = false;
      } else {
        o.children[0].active = true;
      }
    }
  };
  _creator.prototype.showTuJian = function () {
    UIManager.default.open(BundleConfig.BundleNames.Game, UIConfig_Game.UIView_Game.UI_TuJian);
  };
  _creator.prototype.updateLun = function () {
    var e = 1 == GameGlobalVariable.GameGlobalVariable.isTeShuLevel() ? Excel.Excel.shuiguotiaozhan(this.nowlevel) : Excel.Excel.shuiguoguanqia(this.nowlevel);
    var t = this.mosterScript.getNowBoShu();
    if (this.UI_BagNode.active && 1 == GameGlobalVariable.GameGlobalVariable.isTeShuLevel()) {
      this.auto_ui.txt_lunhui.string = "一波合成,怪物无尽来袭";
    } else {
      this.auto_ui.txt_lunhui.string = "第" + t + "/" + e.levelboshuid.length + "波";
    }
  };
  _creator.prototype.onBack = function (e) {
    switch (e) {
      case 1:
        if (1 == GameGlobalVariable.GameGlobalVariable.isTeShuLevel()) {
          EventManager.EventMgr.dispatchEvent(EvenType.EVENT_TYPE.Game_Add_YinBi, 30);
        } else {
          EventManager.EventMgr.dispatchEvent(EvenType.EVENT_TYPE.Game_Add_YinBi, 15);
        }
        this.overstate = 2;
        this.onBackGame();
        this.isover = false;
        break;
      case 2:
        this.overstate = 3;
        this.resetGame();
        BuffMag.BuffMgr.cleanNowCiTiao();
        this.backView();
        GameDataManager.GameDataMgr.ClearGameBagData();
        EventManager.EventMgr.dispatchEvent(EvenType.EVENT_TYPE.Game_Hide);
        EventManager.EventMgr.dispatchEvent(EvenType.EVENT_TYPE.Game_CameraControl, 1);
        break;
      case 3:
        this.setJiaShuState(this.jiasuCode);
        this.isCiTiaoOpen || this.isOpenPuase || this.setGamePuase(false);
        break;
      case 4:
        this.isGameOver = true;
        UIManager.default.open(BundleConfig.BundleNames.Game, UIConfig_Game.UIView_Game.UI_GameOver, {
          type: 1,
          back: this.onBack.bind(this)
        });
    }
  };
  _creator.prototype.onClickBack = function () {
    var e = this;
    this.resetJiaShu();
    this.setGamePuase(true);
    this.isOpenPuase = true;
    UIManager.default.open(BundleConfig.BundleNames.Game, UIConfig_Game.UIView_Game.UI_GamePuase, {
      back: function (t) {
        e.isOpenPuase = false;
        e.onBack(t);
      }
    });
  };
  _creator.prototype.backView = function () {
    GameDataManager.GameDataMgr.updateTiaoZhanJiXu(this.nowlevel, false);
    this.resetJiaShu();
    EventManager.EventMgr.dispatchEvent(EvenType.EVENT_TYPE.Game_Load_View, true);
    this.onHideView();
    UIManager.default.closeAll();
    UIManager.default.open(BundleConfig.BundleNames.Home, UIConfig_Home.UIView_Home.UI_Hall, GameGlobalVariable.GameGlobalVariable.isTeShuLevel());
  };
  _creator.prototype.onHideView = function () {
    this._close();
  };
  _creator.prototype.isGamePass = function () {
    var e = (1 == GameGlobalVariable.GameGlobalVariable.isTeShuLevel() ? Excel.Excel.shuiguotiaozhan(this.nowlevel) : Excel.Excel.shuiguoguanqia(this.nowlevel)).levelboshuid;
    var t = this.mosterScript.mosterboshu + 1;
    return !!e[t] || (GameDataManager.GameDataMgr.updateLevelBoShu(this.nowlevel, t, GameGlobalVariable.GameGlobalVariable.isTeShuLevel()), this.isGameOver = true, this.mosterScript.isCreateMoster = false, this.setGamePuase(true), this.resetJiaShu(), this.isCiTiaoOpen ? undefined : (EventManager.EventMgr.dispatchEvent(EvenType.EVENT_TYPE.Game_Hide), LogManager.LogMgr.info("挑战模式通关"), UIManager.default.open(BundleConfig.BundleNames.Game, UIConfig_Game.UIView_Game.UI_GameOver, {
      type: 2,
      back: this.onBack.bind(this)
    }), false));
  };
  _creator.prototype.huishouBullet = function () {
    var e = this.bulletNode.children;
    var t = this.bulletNode.children.length;
    for (var o = 0; o < t; o++) {
      var n = e[0];
      c = n.getComponent(UI_Bullet.default);
      if (c) {
        NodePoolMag.NodePoolMag.instance.recycleNode("bullet_" + c.bulletId, n);
      }
    }
    var i = GameGlobalVariable.GameGlobalVariable.liulianNode.children;
    var a = i.length;
    for (o = 0; o < a; o++) {
      var r = i[0];
      var c = r.getComponent(UI_BulletMove.default);
      NodePoolMag.NodePoolMag.instance.recycleNode("bullet_" + c.bulletId, r);
    }
  };
  _creator.prototype.isOver = function () {
    var e = this;
    if (this.mosterNode.children.length <= 0) {
      LogManager.LogMgr.debug("当前一轮通关 进入合成界面");
      if (-1 == this.overstate) {
        EventManager.EventMgr.dispatchEvent(EvenType.EVENT_TYPE.GAME_LOCK_SCREE, true);
        if (this.isGamePass()) {
          BuffMag.BuffMgr.saveNowCiTiao();
          BuffMag.BuffMgr.boshuAttackAdd();
          if (1 == GameGlobalVariable.GameGlobalVariable.isTeShuLevel()) {
            this.overstate = 1, this.huishouBullet(), BuffMag.BuffMgr.cleanLiuLian(), this.mosterScript.mosterboshu += 1, GameDataManager.GameDataMgr.updateLevelBoShu(this.nowlevel, this.mosterScript.mosterboshu, GameGlobalVariable.GameGlobalVariable.isTeShuLevel()), this.mosterScript.huishouMoster(), this.updateLun(), this.tiaozhanTip.active = true, this.tiaozhanTip.opacity = 255, this.tiaozhanTip.scaleY = 0, this.tiaozhanTip.children[1].getComponent(cc.Label).string = "第" + this.mosterScript.mosterboshu + "波结束,进入第" + (this.mosterScript.mosterboshu + 1) + "波", this.onTiaoZhanGame(), cc.tween(this.tiaozhanTip).to(.5, {
              scaleY: 1
            }).delay(.5).call(function () {
              EventManager.EventMgr.dispatchEvent(EvenType.EVENT_TYPE.GAME_LOCK_SCREE, false);
            }).to(.25, {
              opacity: 0
            }).call(function () { }).start();
          } else {
            AudioManager.AudioMgr.playEffect("game/sound/boxopen", false, BundleConfig.BundleNames.Game), this.auto_ui.node_playani.active = true, this.auto_ui.node_playani.getComponent(dragonBones.ArmatureDisplay).playAnimation("box", 1), this.scheduleOnce(function () {
              var t = Excel.Excel.shuiguoguanqia(GameGlobalVariable.GameGlobalVariable.nowlevel);
              var o = BuffMag.BuffMgr.overAward(t.yinbi);
              EventManager.EventMgr.dispatchEvent(EvenType.EVENT_TYPE.Game_Add_YinBi, o);
              e.overstate = 1;
              e.scheduleOnce(function () {
                e.auto_ui.node_playani.active = false;
                e.onBackGame();
                EventManager.EventMgr.dispatchEvent(EvenType.EVENT_TYPE.Game_Hide);
                EventManager.EventMgr.dispatchEvent(EvenType.EVENT_TYPE.Game_CameraControl, 1);
              }, 2);
            }, .6);
          }
        }
      }
    }
  };
  _creator.prototype.onMosterDie = function (e) {
    var t = e.moster;
    var o = Excel.Excel.shuiguoguaiwu(t).mosterjinyan;
    o = BuffMag.BuffMgr.playerJingYanValue(o);
    this.roleexperience += o;
    this.updateExperienceUi();
  };
  _creator.prototype.updateExperienceUi = function () {
    var e = this;
    if (!this.isCiTiaoOpen && !this.isGameOver) {
      var t = Excel.Excel.shuiguoneibulevel(this.rolelevel);
      LogManager.LogMgr.info("当前获得经验变化", this.roleexperience, t.jinyan);
      if (this.roleexperience >= t.jinyan) {
        this.isCiTiaoOpen = true;
        this.setGamePuase(true);
        this.roleexperience = this.roleexperience - t.jinyan;
        LogManager.LogMgr.info("剩余经验", this.roleexperience);
        this.rolelevel += 1;
        this.scheduleOnce(function () {
          e.resetJiaShu();
          UIManager.default.open(BundleConfig.BundleNames.Game, UIConfig_Game.UIView_Game.UI_ChiTiao, {
            back: e.backCiTiao.bind(e),
            nowbo: e.mosterScript.getNowBoShu()
          });
        });
      }
      if (this.bottomNd) {
        var o = this.bottomNd.getComponent(UI_SkillShow.default);
        var n = this.roleexperience / t.jinyan;
        o.updateUi(this.rolelevel, n);
      }
      GameDataManager.GameDataMgr.updateRoleLevel(this.nowlevel, this.rolelevel, this.roleexperience, GameGlobalVariable.GameGlobalVariable.isTeShuLevel());
    }
  };
  _creator.prototype.backCiTiao = function () {
    this.setJiaShuState(this.jiasuCode);
    this.isCiTiaoOpen = false;
    this.isCiTiaoOpen || this.isOpenPuase || this.setGamePuase(false);
    this.updateExperienceUi();
  };
  _creator.prototype.initUi = function () {
    return __awaiter(this, undefined, undefined, function () {
      var e;
      var t;
      var o;
      var n;
      var i;
      var a;
      var r;
      var c;
      var u;
      return __generator(this, function (s) {
        switch (s.label) {
          case 0:
            e = null;
            e = 1 == GameGlobalVariable.GameGlobalVariable.isTeShuLevel() ? Excel.Excel.shuiguotiaozhan(this.nowlevel) : Excel.Excel.shuiguoguanqia(this.nowlevel);
            t = new Date().getTime();
            o = this.auto_ui.node_bg.getComponent(cc.Sprite);
            n = this.auto_ui.node_chaoxue.getComponent(cc.Sprite);
            i = this.auto_ui.node_lu.getComponent(cc.Sprite);
            return [4, this._loadRes(BundleConfig.BundleNames.Game, "game/" + "res/bg/changjin/场景" + e.dipicture, cc.SpriteFrame)];
          case 1:
            a = s.sent();
            o.spriteFrame = a;
            r = [{
              x: -63.189,
              y: 529.428
            }, {
              x: -63.189,
              y: 529.428
            }, {
              x: -38.237,
              y: 560.618
            }, {
              x: -61.717,
              y: 536.019
            }];
            return [4, this._loadRes(BundleConfig.BundleNames.Game, "game/" + "res/bg/caoxue" + e.dipicture, cc.SpriteFrame)];
          case 2:
            c = s.sent();
            n.spriteFrame = c;
            n.node.x = r[e.dipicture - 1].x;
            n.node.y = r[e.dipicture - 1].y;
            return [4, this._loadRes(BundleConfig.BundleNames.Game, "game/" + "res/bg/lu" + e.dipicture, cc.SpriteFrame)];
          case 3:
            u = s.sent();
            i.spriteFrame = u;
            LogManager.LogMgr.info("背景底图时间差", new Date().getTime() - t);
            this.loadUiBag();
            if (1 == GameGlobalVariable.GameGlobalVariable.isTeShuLevel()) {
              this.auto_ui.txt_level.string = "无尽试炼";
            } else {
              this.auto_ui.txt_level.string = "第" + this.nowlevel + "章";
            }
            if (cc.winSize.height / cc.winSize.width < 2) {
              this.tongjiNode.active = false;
            } else {
              this.tongjiNode.active = true;
            }
            this.updateLun();
            this.setJiaShuState(1);
            return [2];
        }
      });
    });
  };
  _creator.prototype.loadUiBag = function () {
    return __awaiter(this, undefined, undefined, function () {
      var e;
      return __generator(this, function (t) {
        switch (t.label) {
          case 0:
            if (this.nowBag) {
              return [3, 2];
            } else {
              return [4, this._loadRes(BundleConfig.BundleNames.Game, "game/" + "prefabs/hecheng/UI_Bag", cc.Prefab)];
            }
          case 1:
            e = t.sent();
            this.nowBag = cc.instantiate(e);
            t.label = 2;
          case 2:
            this.UI_BagNode.addChild(this.nowBag);
            EventManager.EventMgr.dispatchEvent(EvenType.EVENT_TYPE.Game_Load_View, false);
            return [2];
        }
      });
    });
  };
  _creator.prototype.onClickTongGuan = function () {
    var e;
    this.overstate = 1;
    e = 1 == GameGlobalVariable.GameGlobalVariable.isTeShuLevel() ? Excel.Excel.shuiguotiaozhan(this.nowlevel) : Excel.Excel.shuiguoguanqia(this.nowlevel);
    this.mosterScript.mosterboshu = e.levelboshuid.length;
    this.isGamePass();
  };
  _creator.prototype.onClickCiTiao = function () {
    UIManager.default.open(BundleConfig.BundleNames.Game, UIConfig_Game.UIView_Game.UI_ChiTiao, {
      back: this.backCiTiao.bind(this)
    });
  };
  _creator.prototype.setCiTiaoContent = function (e) {
    var t = e.citiaomiaoshu;
    var o = Excel.Excel.shuiguobuff(e.citiaoshuzhitype);
    var n = [];
    for (var i = 0; i < o.value.length; i++) {
      var a = o.value[i];
      n.push(a + "");
    }
    return CommonUtils.default.replaceSymbols(t, "X", n);
  };
  __decorate([_property(UI_GameView_UIBindings.default)], _creator.prototype, "auto_ui", undefined);
  __decorate([_property(cc.Node)], _creator.prototype, "UI_BagNode", undefined);
  __decorate([_property(cc.Node)], _creator.prototype, "mosterNode", undefined);
  __decorate([_property(cc.Node)], _creator.prototype, "pathsNode", undefined);
  __decorate([_property(cc.Node)], _creator.prototype, "playerNode", undefined);
  __decorate([_property(cc.Node)], _creator.prototype, "bulletNode", undefined);
  __decorate([_property(cc.Node)], _creator.prototype, "languaNode", undefined);
  __decorate([_property(cc.Node)], _creator.prototype, "liulianNode", undefined);
  __decorate([_property(cc.Node)], _creator.prototype, "othereff", undefined);
  __decorate([_property(cc.Node)], _creator.prototype, "aixinNode", undefined);
  __decorate([_property(cc.Node)], _creator.prototype, "mapNode", undefined);
  __decorate([_property(cc.Node)], _creator.prototype, "tiaozhanTip", undefined);
  __decorate([_property(cc.Node)], _creator.prototype, "tongjiNode", undefined);
  __decorate([_property(cc.Node)], _creator.prototype, "bottmoNode", undefined);
  __decorate([_property(cc.Node)], _creator.prototype, "jinjieEffNode", undefined);
  __decorate([_property(cc.Node)], _creator.prototype, "playereffNode", undefined);
  __decorate([_property(cc.Node)], _creator.prototype, "addYinBiBtn", undefined);
  __decorate([_property(cc.Node)], _creator.prototype, "boosTip", undefined);
  __decorate([_property(cc.Node)], _creator.prototype, "fankuiNode", undefined);
  __decorate([_property(UI_ShowAttackInfo.default)], _creator.prototype, "showattackinfo", undefined);
  return __decorate([_ccclass], _creator);
}(UIView.default);
exports.default = _def_UI_GameView;